<?php
#程序计时器
$GLOBALS['emvc_start_time']= array_sum(split(' ', microtime()));
function timer(){
	global $emvc_start_time;
	$end_time = array_sum(split(' ', microtime()));
	$var=sprintf('%.6f',$end_time-$emvc_start_time);
	echo '<div style="color:green;">Powered by Emvc! Parse Time:'.$var.'s</div>';
}
# 变量调试器
function debug() {
	$args = func_get_args();
	echo '---------------------debug info.---------------------<pre>';
	foreach ($args as $value) {
		if(is_null($value)){
			echo '[is_null]';
		}elseif(is_bool($value) || empty($value)){
			var_dump($value);
		}else{
			print_r($value);
		}
		echo '<br>';
	}
	$trace=debug_backtrace();
	$next = array_merge(
					array(
						'line'		=> '??',
						'file'		=> '[internal]',
						'class'		=> null,
						'function'	=> '[main]'
					),
					$trace[0]
				);
	if(strpos($next['file'],EMVC_PATH_LIBRARIES)===0){
		$next['file'] = str_replace(EMVC_PATH_LIBRARIES, DS.'Libraries'.DS,$next['file']);
	}elseif(strpos($next['file'],EMVC_PATH_ROOT)===0){ 
		$next['file'] = str_replace(EMVC_PATH_ROOT, DS.'Webroot'.DS,$next['file']);
	}
	echo '---------------------debug ended---------------------';
	echo '<div style="color:red;">'.$next['file'].' line:'.$next['line'].'</div>';
	if(in_array('debug',$args)){
		print_r($trace);
	}
	timer();
	echo '</pre>';
	exit();
}
?>